package com.ctshk.app.train.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.train.dto.h5.HomeTrainH5DTO;
import com.ctshk.rpc.train.dto.h5.TrainProductSeatH5DTO;
import com.ctshk.rpc.train.dto.pc.TrainProductDetailPcDTO;
import com.ctshk.rpc.train.req.TrainAppQueryReq;
import com.ctshk.rpc.train.req.TrainDetailAppQueryReq;
import com.ctshk.rpc.train.service.CJTrainProductService;
import com.ctshk.rpc.train.service.ITrainProductAppAndPcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 火车产品表 前端控制器
 * </p>
 *
 * @author 彭柳霖
 * @since 2021-03-11
 */
@Api(value="PC端-火车产品接口", tags="PC端-火车产品接口")
@RestController
@RequestMapping("/train-product")
public class TrainProductController extends BaseController {

    @DubboReference
    ITrainProductAppAndPcService trainProductAppServiceImpl;

    @DubboReference
    private CJTrainProductService cjTrainProductService;

    @ApiOperation(value="火车票-首页-热门路线-查询", notes="火车票-首页-热门路线-查询")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "火车票-首页-热门路线-查询", operDesc = "火车票-首页-热门路线-查询")
    @GetMapping("/hotline/query")
    public Result<HomeTrainH5DTO> hotLineQuery() {
        return trainProductAppServiceImpl.hotLineQuery();
    }

    @ApiOperation(value="火车票-首页-查询列表", notes="火车票-首页-查询列表")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "火车票-首页-查询列表", operDesc = "火车票-首页-查询列表")
    @PostMapping("/reservation/query")
    public Result<List<TrainProductSeatH5DTO>> reservationQuery(@RequestBody @Valid TrainAppQueryReq req) {
        return trainProductAppServiceImpl.reservationQueryPc(req);
    }

    @ApiOperation(value="火车票-查询产品详情", notes="火车票-查询产品详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "火车票-查询产品详情", operDesc = "火车票-查询产品详情")
    @PostMapping("/detail/query")
    public Result<TrainProductDetailPcDTO> queryDetail(@RequestBody @Valid TrainDetailAppQueryReq req) {
        return trainProductAppServiceImpl.queryDetailWithAli(req);
    }
}
